package com.learn.acm.bytedance;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author zhongshitao
 * @date 2020/9/23 3:57 下午
 */
public class Solution146 {



}



class LRUCache extends LinkedHashMap<Integer, Integer> {

    private Integer capacity;

    public LRUCache(int capacity) {
        super(capacity,0.75f, true);
        this.capacity = capacity;

    }

    public int get(int key) {
        return super.getOrDefault(key, -1);
    }

    public void put(int key, int value) {
        super.put(key, value);
    }


    @Override
    protected boolean removeEldestEntry(Map.Entry eldest) {
        return size() > capacity;
    }
}
